/**
 * Created by xyy on 2017/6/27.
 */
export class DateUtil{
  /**日期转字符串 yyyy-MM-dd */
  public static getStrDate(date: Date): string{
    let year = date.getFullYear();
    let month = date.getMonth()+1;
    let day = date.getDate();
    return year + "-" + (month<10?'0'+month:month) + "-" + (day<10?'0'+day:day);
  }
  /**完整的日期字符串 yyyy-MM-dd HH:mm:ss */
  public static getStrFullDate(date:Date):string{
    let hours = date.getHours();
    let minutes = date.getMinutes();
    let seconds = date.getSeconds();
    return DateUtil.getStrDate(date)+" "+(hours<10?'0'+hours:hours)+":"
      +(minutes<10?'0'+minutes:minutes)+":"+(seconds<10?'0'+seconds:seconds);
  }

}
